<?php
require_once '../Miffos/Tools.php';

echo "<h1>function: array2object(array,\$sub=false)</h1>";
/**
 * Experiment with function array2object
 */  

/**
 * Normal 1 array
 */ 
echo "<h2>1 <b style='color:red'>array</b> | no sub array</h2>\n";

$array = array("mykey"=>"myvalue","experiment"=>"yes");

var_dump(array2object($array));

/**
 * array with sub array and sub edit array is on
 */ 
echo "<h2>1 <b style='color:red'>array</b> | sub array is on</h2>\n";

$array = array("mykey"=>"myvalue","experiment"=>"yes",array("mykey2"=>"2myvalue","2experiment"=>"2yes","subobject"=>array("mykey"=>"myvalue","experiment"=>"yes")));

var_dump(array2object($array,true));

/**
 * array with sub array and sub edit array is off
 */ 
echo "<h2>1 <b style='color:red'>array</b> | sub array is off</h2>\n";

$array = array("mykey"=>"myvalue","experiment"=>"yes",array("mykey2"=>"2myvalue","2experiment"=>"2yes","subobject"=>array("mykey"=>"myvalue","experiment"=>"yes")));

var_dump(array2object($array,false));

/* -------------------------------------------------------- */
echo "<br><br><hr>";
echo "<h1>function: object2array(object,\$sub=false)</h1>";

/**
 * Experiment with function object2array
 */  

/**
 * Normal 1 array
 */ 
$object = (object) $c;
$object->aha = "ja jsem jelen";
$object->ahojik = "Zdravim";

echo "<h2>1 <b style='color:blue'>object</b> | no sub object</h2>\n";

$array = array("mykey"=>"myvalue","experiment"=>"yes");

var_dump(object2array($object));

/**
 * array with sub array and sub edit array is on
 */
 
$object->class = (object) $y;
$object->class->jupi = "ano jupi";
 
echo "<h2>1 <b style='color:blue'>object</b> | sub object is on</h2>\n";

$array = array("mykey"=>"myvalue","experiment"=>"yes",array("mykey2"=>"2myvalue","2experiment"=>"2yes","subobject"=>array("mykey"=>"myvalue","experiment"=>"yes")));

var_dump(object2array($object,true));

/**
 * array with sub array and sub edit array is off
 */ 
echo "<h2>1 <b style='color:blue'>object</b> | sub object is off</h2>\n";


var_dump(object2array($object,false)); // object2array($array,false)


?>